package cn.kimming.service.impl;

import cn.kimming.mapper.CheckInfoMapper;
import cn.kimming.mapper.OrderbillMapper;
import cn.kimming.mapper.RoomPlanMapper;
import cn.kimming.mapper.RoomTypeMapper;
import cn.kimming.service.IChartService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 刘铭轩
 * date 2021-06-24
 */
@Service
public class ChartServiceImpl implements IChartService {
    @Autowired
    private OrderbillMapper orderbillMapper;
    @Autowired
    private CheckInfoMapper checkInfoMapper;
    @Autowired
    private RoomPlanMapper roomPlanMapper;
    @Autowired
    private RoomTypeMapper roomTypeMapper;

    @Override
    public JSONObject getTodayInfo() {
        Long orderbillCount = orderbillMapper.findTodayCount();
        Long checkInCount = checkInfoMapper.findTodayCount();
        JSONObject info = new JSONObject();
        info.put("orderbillCount", orderbillCount);
        info.put("checkInCount", checkInCount);
        return info;
    }

    @Override
    public List<JSONObject> getTodayRoomTypeLeft() {
        return roomPlanMapper.getTodayRoomTypeLeft();
    }

    @Override
    public List<JSONObject> getRecentOrderCounts() {
        return orderbillMapper.getRecentOrderCounts();
    }

    @Override
    public List<JSONObject> getMonthTypeLiveRate() {
        return roomTypeMapper.getMonthTypeLiveRate();
    }

    @Override
    public List<JSONObject> getMonthOrderAmount() {
        return orderbillMapper.getMonthOrderAmount();
    }
}
